import type { ConfigType, Dayjs } from 'dayjs'
import dayjs from 'dayjs'

const DATE_FORMAT = 'YYYY-MM-DD'
const DATE_TIME_FORMAT = 'YYYY-MM-DD HH:mm:ss'

const formatToDateTime = (
  date: ConfigType,
  format = DATE_TIME_FORMAT
): string => {
  return dayjs(date).format(format)
}

const formatToDate = (date: ConfigType, format = DATE_FORMAT): string => {
  return dayjs(date).format(format)
}

const formatToDayjs = (date: ConfigType): Dayjs => {
  return dayjs(date)
}

export const bwUtilsDate = {
  dayjs,
  formatToDateTime,
  formatToDate,
  formatToDayjs,
}
